import allure
import requests
from jsonpath import jsonpath
from common.base_api import BaseApi
class ProductApi(BaseApi):
    def login_api(self, username=BaseApi().account['username'], password=BaseApi().account['password']):

        api = "/api/user/login"
        data ={
            'url': self.host+api,
            'method': 'POST',
            # 'headers': self.headers,
            'json': {
                'username': username,
                'password': password
            }

        }

        response = self.send_http(data)
        return response

    def get_login_data(self, username=BaseApi().account['username'], password=BaseApi().account['password']):
        response = self.login_api(username=username, password=password)
        res = response.json()
        login_data =dict()
        login_data['token'] =res['data']['token']
        login_data['id'] = res['data']['id']
        login_data['username'] = res['data']['user']
        return login_data
if __name__ == '__main__':
    print(ProductApi().login_api())


